package FileCopy;

import java.io.*;

public class FileCopyIO {
    public static void main(String[] args) {
        try (InputStream input = new FileInputStream(new File("data.bin"));
             OutputStream output = new FileOutputStream(new File("dataTargetIO.bin"))){
            byte[] buf = new byte[65536];
            int bytesRead;
            long start = System.currentTimeMillis();
            while ((bytesRead = input.read(buf)) > 0) {
                output.write(buf, 0, bytesRead);
            }
            long end = System.currentTimeMillis();
            System.out.println("Time: " + (end - start) + " ms");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
